
package org.ricks.ioc.scheduler;

import java.util.Date;

/**
 * CRON表达式类型的触发器.
 */
public class CronTrigger extends DelayTrigger {

    private final CronExpression expression;

    public CronTrigger(String cron) {
        this(new CronExpression(cron));
    }

    public CronTrigger(CronExpression expression) {
        super(expression.next(new Date()).getTime());
        this.expression = expression;
    }

    @Override
    public long triggerTime() {
        trigger = expression.next(new Date(trigger)).getTime();
        return trigger;
    }
}